package com.oro.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 * Entity implementation class for Entity: Quote
 * 
 */
@Entity
public class Quote implements Serializable {

	private static final long serialVersionUID = 1L;

	@ManyToOne
	@JoinTable(name = "quote_user")
	private User author;

	private Date date;

	private float discountedCost;

	@Id
	@GeneratedValue
	private Long id;

	@OneToMany
	@JoinTable
	private List<Proposal> proposals;

	@ManyToOne
	@JoinTable(name = "quote_studente")
	private Studente studente;

	private float totalCost;

	public Quote() {
		super();
		proposals = new ArrayList<Proposal>();
	}

	public User getAuthor() {
		return author;
	}

	public Date getDate() {
		return date;
	}

	public float getDiscountedCost() {
		float result = 0f;
		for (Proposal p : proposals)
			result += p.getDiscountedCost();
		return result;
	}

	public Long getId() {
		return id;
	}

	public List<Proposal> getProposals() {
		return proposals;
	}

	public Studente getStudente() {
		return studente;
	}

	public float getTotalCost() {
		float result = 0f;
		for (Proposal p : proposals)
			result += p.getTotalCost();
		return result;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setDiscountedCost(float discountedCost) {
		this.discountedCost = discountedCost;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setProposals(List<Proposal> proposals) {
		this.proposals = proposals;
	}

	public void setStudente(Studente studente) {
		this.studente = studente;
	}

	public void setTotalCost(float totalCost) {
		this.totalCost = totalCost;
	}

}
